package com.sky.happygos.YiPush;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.support.v7.app.NotificationCompat;

import com.sky.happygos.R;
import com.sky.happygos.ui.activity.MainA;
import com.sky.happygos.ui.activity.MainA_;

/**
 * Created by qqqqqqq on 2017/4/21.
 */

public class NotificationManagerU {

    public static final int TYPE_Normal = 1;
    public static final int TYPE_Progress = 2;
    public static final int TYPE_BigText = 3;
    public static final int TYPE_Inbox = 4;
    public static final int TYPE_BigPicture = 5;
    public static final int TYPE_Hangup = 6;
    public static final int TYPE_Media = 7;
    public static final int TYPE_Customer = 8;

    public static NotificationManager notificationManager;


    public static void show(Context context,Msg msg){
        if(notificationManager == null){
            notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        }
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setContentTitle("订单提醒");
        builder.setContentText(msg.data);
        builder.setDefaults(NotificationCompat.DEFAULT_ALL);
        builder.setSmallIcon(R.drawable.app_icon);
        builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),R.drawable.app_icon));
        Intent intent = new Intent(context,MainA_.class);
        intent.putExtra(MainA.EXTRA_TAB,1);
        PendingIntent pIntent = PendingIntent.getActivity(context,1,intent,0);
        builder.setContentIntent(pIntent);
        builder.setFullScreenIntent(pIntent,true);
        builder.setAutoCancel(true);
        Notification notification = builder.build();
        notificationManager.notify(TYPE_Hangup,notification);
    }

    public static Notification getLongNotification(Context context){
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setContentTitle("运行状态");
        builder.setContentText("开店中");
        builder.setDefaults(NotificationCompat.DEFAULT_ALL);
        builder.setSmallIcon(R.drawable.app_icon);
        builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),R.drawable.app_icon));
        Intent intent = new Intent(context,MainA_.class);
        PendingIntent pIntent = PendingIntent.getActivity(context,1,intent,0);
        builder.setContentIntent(pIntent);
//        builder.setFullScreenIntent(pIntent,true);
        builder.setPriority(NotificationCompat.PRIORITY_MAX);
        return builder.build();
    }
}
